package com.edu.exam.enums.curriculum.teaching;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 分配状态枚举
 *
 * 教师分配的状态定义
 *
 * @author System
 * @version 1.0.0
 */
public enum AssignmentStatus implements BaseEnum {
    PROPOSED("PROPOSED", "提议中"),
    CONFIRMED("CONFIRMED", "已确认"),
    ACTIVE("ACTIVE", "活跃"),
    COMPLETED("COMPLETED", "已完成"),
    SUSPENDED("SUSPENDED", "暂停"),
    REASSIGNED("REASSIGNED", "已调整");

    private final String code;
    private final String description;

    AssignmentStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static AssignmentStatus fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("AssignmentStatus code cannot be null or empty");
        }
        for (AssignmentStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown assignment status code: " + code);
    }

    public static AssignmentStatus fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            throw new IllegalArgumentException("AssignmentStatus description cannot be null or empty");
        }
        for (AssignmentStatus status : values()) {
            if (status.getDescription().equals(description)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown assignment status description: " + description);
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}